//
//  SMHSettingCell.swift
//  SMHCommerce
//
//  Created by lvzhao on 2020/6/6.
//  Copyright © 2020 lvzhao. All rights reserved.
//

import UIKit

class SMHSettingCell: LZBaseTableViewCell {

    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    //MARK:srtupUI
    func setupUI() {
        
        self.contentView.addSubview(self.titleLab)
        self.titleLab.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.contentView.snp.centerY)
            make.left.equalTo(15)
            make.width.equalTo(170)
            make.height.equalTo(20)
        }
        
        
        self.contentView.addSubview(self.detailLab)
        self.detailLab.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.contentView.snp.centerY)
            make.right.equalTo(-30)
            make.width.equalTo(170)
            make.height.equalTo(20)
        }
        
        self.rightImageView.isHidden = false
        self.lineView.isHidden = false
    }
    

    var modelObject : Any? {
        didSet{
            let settingModel = modelObject as! SMHSettingModel
            self.titleLab.text = settingModel.title
            self.detailLab.text = settingModel.detail
            
            if self.titleLab.text == "清除缓存" {
                self.rightImageView.isHidden = true
                self.detailLab.snp.updateConstraints { (make) in
                    make.right.equalTo(-15)
                }
            } else {
                self.rightImageView.isHidden = false
                self.detailLab.snp.updateConstraints { (make) in
                    make.right.equalTo(-30)
                }
            }
            
            
        }
    }
    
    lazy var titleLab : UILabel = {
        let titleLab = UILabel()
        titleLab.font = ktextFont(size: 15)
        titleLab.textColor = UIColorFromHex(rgbValue: 0x363636)
        return titleLab
    }()
    
    
    lazy var detailLab : UILabel = {
        let detailLab = UILabel()
        detailLab.font = ktextFont(size: 14)
        detailLab.textColor = UIColorFromHex(rgbValue: 0xA8A8A8)
        detailLab.textAlignment = .right
        return detailLab
    }()
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
